Repository navigation
Public text guard: a hashed denylist in the repository, and a step in CI - #483
Merged
Merged
Conversation
The guard now fails on any term whose SHA-256 is in .github/text-guard.sha256. Terms are normalized (lowercase, every run of other characters one space), and the guard hashes every run of 1 to 4 words of each line it checks, and every 12-digit number, so the file names no term. The failure says only the line and "denylisted term". `text_guard.py --hash-terms` hashes a list read from standard input. GUARD_DENYLIST stays as an optional extra. A new rule fails on any standalone 12-digit number, apart from AWS's placeholder ids, so account ids are caught without being listed. CI's first job runs the guard on every push to a PR, so a PR whose title, body, commits or docs additions carry an install's details goes red in CI. The Public text guard workflow now runs only when the PR's text is edited. Tests use synthetic terms hashed in the test itself.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Public text guard no longer needs a secret or a required check. It reads a list of SHA-256 digests committed to the repository, and it runs as a step in CI's first job, so a PR with a leak goes red in CI.
Changes
.github/scripts/text_guard.py:.github/text-guard.sha256. Text is normalized: lowercase, and every run of anything but letters and digits becomes one space. The guard hashes every run of 1 to 4 words of each line, and every 12-digit number (with or without dashes). The failure names only the line and the rule.python3 .github/scripts/text_guard.py --hash-terms < terms.txtprints one digest per term, and never prints a term.GUARD_DENYLISTis still read when it is set, as an optional extra..github/text-guard.sha256: the digest list, one per line, with a header saying how to add terms. It ships with the header only..github/workflows/ci.yml: the first job (Workflow security here, Lint & Build in the site repo) now checks out the full history and runs the guard's tests, then the guard, on every pull request push..github/workflows/text-guard.ymlnow runs only onedited, so an edit to the title or body is checked without rerunning CI..github/scripts/test_text_guard.py: tests for normalization, 1- to 4-word runs, parts and neighbours of a term that must not match, 12-digit numbers, the digest file's format, and a failure that prints no term. Every term is synthetic and is hashed inside the test.Verification